<%@ page language="java" import="com.imaker.domain.*,java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    <title></title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/common.css">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/gridPanel.css">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/toolBar.css">
	<link rel="stylesheet" type="text/css" href="js/plugin/frame/css/windowPanel.css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/plugin/frame/toolBar.js"></script>
	<script type="text/javascript" src="js/plugin/frame/GridPanel.js"></script>
	<script type="text/javascript" src="js/plugin/frame/windowPanel.js"></script>
	<script type="text/javascript" src="js/page/user.js"></script>
	<script type="text/javascript" src="js/validate.js"></script>
  </head>
  <body>
  <form action="<%=path %>/system/user/list.action" id="form" name="form">
  			<table id="titleTable">
  				<tr>
  					<td><span></span></td>
  					<td><span>用户名称</span></td>
  					<td><span>真实姓名</span></td>
  					<td><span>性别</span></td>
  					<td><span>部门</span></td>
  					<td><span>创建时间</span></td>
  				</tr>
  				</table>
  				<table id="dataTable">
  					<s:iterator id="user" value="page.list"  status="i">
	  					<tr>
	  						<td><span><input type="checkbox" name="idList" value="<s:property value="#user.id"/>"/></span></td>
	  						<td><span><s:property value="#user.userName"/> </span></td>
	  						<td><span><s:property value="#user.realName"/></span></td>
	  						<td><span><s:property value="#user.sex"/></span></td>
	  						<td><span><s:property value="#user.department.name"/></span></td>
	  						<td><span><s:date name="#user.createDate" format="yyyy-MM-dd"/> </span></td>
	  					</tr>
  					</s:iterator>
  				</table>
  				<s:hidden name="department.id" id="departmentId"></s:hidden>
  				</form>
	  	<script type="text/javascript">
	  	var path = '<%=path%>';
		$(document).ready(function(){
		//创建表格控件
		new GridPanel({
		title : '用户管理',
		titleTable : 'titleTable',
		dataTable : 'dataTable',
		width:[25,200,200,180,180,],
		toolBar : true
		});
		//添加toolBar
		var toolBar = new ToolBar({
			renderTo : 'toolBar',
			items : [{
				text : '新建',
				pic : 'add',
				userable:'true',
				handler : function(){
				userFunction.saveWindow($("#departmentId").val());
				}		
			},'-',{
				text:'修改',
				pic:'edit',
				userable:'true',
				handler:function(){
				if(getSelectId().length==0){
				   		alert("请选择要操作的记录");
				   		return;
				   }
				   userFunction.updateWindow(getSelectId()[0]);
				}
			},'-',{
				text:'查看',
				pic:'view',
				userable : 'true',
				handler : function(){
				   if(getSelectId().length==0){
				   		alert("请选择要操作的记录");
				   		return;
				   }
				}
			},'-',{
				text:'删除',
				pic:'delete',
				userable : 'true',
				handler : function(){
					if(getSelectId().length==0){
				   		alert("请选择要操作的记录");
				   		return;
				   }
				   if(confirm("确认删除!")){
				    $("#form").attr("action","<%=path %>/system/user/delete.action");
					$("#form").submit();
					}
				}
			},'-',{
				text:'关联角色',
				pic:'role',
				useable : true,
				handler :function(){
					if(getSelectId().length==0){
				   		alert("请选择要操作的记录");
				   		return;
				   }
				   userFunction.userRoleWindow(getSelectId()[0]);
				}
			}]
				
		}).render();
		});
	  	</script>
  </body>
</html>
